#!/usr/bin/env bash

set -u
set -e


IMAGE_NAME="admin-server"
IMAGE_ID=$(date +%Y%m%d)
echo "============== image tag : ${IMAGE_ID}"
IMAGE_REGISTRY="registry.cn-beijing.aliyuncs.com"
IMAGE_NAMESPACE="hiboe"
IMAGE_FULLNAME=$IMAGE_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$IMAGE_ID


REGISTRY_USERNAME="t_1516617822136_0451"
REGISTRY_PASSWORD="woms0613"
echo "${REGISTRY_PASSWORD}" | docker login $IMAGE_REGISTRY -u "${REGISTRY_USERNAME}" --password-stdin


docker pull "${IMAGE_FULLNAME}"
docker stop ${IMAGE_NAME} || true
docker rm ${IMAGE_NAME} || true


docker run -d -p 5000:5000 \
--name ${IMAGE_NAME} \
-v /tmp:/application/logs \
--restart=always \
--env-file ./dev.env \
"${IMAGE_FULLNAME}"







